Conversation
8a0fcf9 to
e2dc5bc
Compare
|
|
||
| #include "presto_cpp/main/dynamic_registry/DynamicFunctionRegistrar.h" | ||
| #include "velox/expression/SimpleFunctionRegistry.h" | ||
| #include <iostream> |
There was a problem hiding this comment.
This goes to the top of the list.
| // (note the extern "C" directive to prevent the compiler from mangling the | ||
| // symbol name). | ||
|
|
||
| namespace facebook::velox::common::dynamicRegistry { |
There was a problem hiding this comment.
Why this namespace? This is an example so the user could choose whatever namespace they have. I would change this away from a velox namespace and not use velox or presto namespace to indicate complete freedom.
There was a problem hiding this comment.
Agree... we could use a namespace that is more representative of the current folder structure.
| #include "presto_cpp/main/dynamic_registry/DynamicFunctionRegistrar.h" | ||
| #include "velox/expression/SimpleFunctionRegistry.h" | ||
| #include <iostream> | ||
| // This file defines a mock function that will be dynamically linked and |
There was a problem hiding this comment.
This isn't technically a mock function. It is a real function that carries out an addition.
| return prestoRoot | ||
| .resolve("presto-native-execution") | ||
| .resolve("_build") | ||
| .resolve("release") |
There was a problem hiding this comment.
Can we change this an be able to check if release exists here and if not use debug? That would handle the case if the build type changes that you don't have control over here.
aditi-pandit
left a comment
There was a problem hiding this comment.
Thanks @pramodsatya. Have bunch of comments.
There was a problem hiding this comment.
There shouldn't be a need to derive this class from one in presto-tests. We can make TestCustomFunctions a presto-native-tests only class. wdyt ?
There was a problem hiding this comment.
Thanks for the suggestion, I agree.
There was a problem hiding this comment.
This function should be a part of presto-native-tests and can be built by default. There isn't a need to put in the dynamic_registrations examples and set PRESTO_ENABLE_EXAMPLES for it. presto-native-execution needn't be changed at all.
Though you would need to create a top-level cpp code folder in presto-native-tests. So something like add them in a presto_cpp/tests/custom_functions folder.
There was a problem hiding this comment.
Could we keep all C++ UDFs used in e2e tests in presto-native-execution/presto_cpp/main/dynamic_registry/examples, similar to how the Java test UDFs are all placed under presto-tests/src/main/java/com/facebook/presto/tests? Keeping them in presto-native-execution would ensure different dynamic libraries like .so and .dylib for Linux/Mac are suitably built during linux-build process in CI. Also the presto-native-tests CI workflow has a dependency on linux-build CI workflow, ensuring the dynamic libraries are built first. Otherwise, we could also leverage the container based testing framework for this? What do you suggest?
There was a problem hiding this comment.
agree with @pramodsatya that having the linux-build process in CI as a dependency would build the libraries first. Also, keeping them under examples, for all other test files we come up with, users can take advantage of reading the code to these files if they stumble upon the dynamic registry function docs as well which could be advantageous.
if we were to build these in cpp in presto-native-tests, they will be built in presto-native-tests after the presto-native-execution build occurs in the linux-build workflow.
afaik, that should be fine if we can be sure that these dynamic files will be built before the test is run. @pramodsatya do you know if that can be made to be the case that the new cpp build for would happen before the E2E test run?
the other thing too, fmt::fmt gflags::gflags xsimd, would be dependencies for these libraries to build and we need to ensure that these will be available for the presto-native-tests cpp build.
There was a problem hiding this comment.
So Java test udfs are in a testing specific directory... Its better to separate tests from examples. The examples are demo examples that are documentation. You can build the tests in the linux-build workflow if that is more convenient.
There was a problem hiding this comment.
@pramodsatya @soumiiow : There is value to showing a custom function example that is not in presto-native-execution. Any user is more likely to copy that setup since they will write their functions in new java/cpp modules.
There was a problem hiding this comment.
hey @aditi-pandit just to clarify, id make a Makefile, Cmakelists, put src files, etc and essentially build this completely under, say presto/presto-native-tests/presto-cpp/tests/custom_functions is that a correct interpretation of the ask?
There was a problem hiding this comment.
Yes @soumiiow...
The build command for it can be in linux-build workflow if you prefer.
| // (note the extern "C" directive to prevent the compiler from mangling the | ||
| // symbol name). | ||
|
|
||
| namespace facebook::velox::common::dynamicRegistry { |
There was a problem hiding this comment.
Agree... we could use a namespace that is more representative of the current folder structure.
| } // namespace facebook::velox::common::dynamicRegistry | ||
|
|
||
| extern "C" { | ||
| // In this case, we assume that facebook::presto::registerPrestoFunction |
There was a problem hiding this comment.
Don't follow this comment... registerPrestoFunction is available if you include the necessary header in this file.
| namespace facebook::velox::common::dynamicRegistry { | ||
|
|
||
| template <typename T> | ||
| struct DynamicFunctionCustomAdd { |
There was a problem hiding this comment.
This name can be simply CustomAdd
| /// Custom aggregate functions are unsupported in Presto C++. | ||
| @Override | ||
| @Test (enabled = false) | ||
| public void testCustomSum() {} |
There was a problem hiding this comment.
These 2 test functions are not needed at all.
| /// Sidecar is needed to support custom functions in Presto C++. | ||
| @Override | ||
| @Test | ||
| public void testCustomAdd() |
There was a problem hiding this comment.
As we are adding a new test for dynamic functions, we can add more scalar functions with a variety of simple types, array, map and struct based functions... nested types as well.
|
|
||
| public static Path getCustomFunctionsPluginDirectory() | ||
| { | ||
| Path workingDir = Paths.get(System.getProperty("user.dir")).toAbsolutePath(); |
There was a problem hiding this comment.
We should update the docs at https://github.com/prestodb/presto/tree/master/presto-native-tests#presto-native-tests as well for this config.
There was a problem hiding this comment.
This path cannot be set in jvm arguments and its value is fixed, we intend to keep all the C++ UDFs used in e2e tests in presto-native-execution under the path presto_cpp/main/dynamic_registry/examples. Could you please confirm if this needs to be documented?
e2dc5bc to
ce68951
Compare
56fee7c to
d7df27e
Compare
574bacf to
471ebcc
Compare
|
@pramodsatya & @mohsaka : Please can you merge your commits. |
28892b2 to
d9fcc4c
Compare
e2ff78e to
ff0d683
Compare
aditi-pandit
left a comment
There was a problem hiding this comment.
@mohsaka : This code is looking good minus the question about the test.
| private boolean sidecarEnabled; | ||
|
|
||
| @BeforeSuite | ||
| public void buildNativeLibrary() |
There was a problem hiding this comment.
Am still not sure I follow : Why can we not do this in the pipeline ?
ff0d683 to
36273b1
Compare
|
@mohsaka : There are velox update files in this PR. Do you need them or this was an accident ? I'll send an Advance Velox PR nonetheless. |
Sorry, did not intend to advance velox. Will remove it |
36273b1 to
45b9801
Compare
6633845 to
72b0506
Compare
Co-authored-by: Pramod Satya <pramod.satya@ibm.com> Co-authored-by: soumiiow <soumyaduriseti@gmail.com>
72b0506 to
fb09bb5
Compare
Description
Adds e2e tests for Presto C++ custom functions. Testcases borrowed from AbstractTestQueries in
presto-tests.